package com.hedl.practice.diyJava.network_programming.TCP_programming.server;

import com.hedl.practice.diyJava.network_programming.TCP_programming.utils.Handler;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(6666);       //监听指定端口号
        System.out.println("server is running...");
        for (;;){
            Socket sock = ss.accept();      //侦听对此套接字的连接并接受它。
            System.out.println("connected from "+sock.getRemoteSocketAddress());        //返回此套接字连接到的端点的地址，如果未连接则返回 null
            Thread t = new Handler(sock);
            t.start();
        }
    }
}
